home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / asa / notes < prev    next >
Text File  |  1994-10-23  |  14KB  |  400 lines

  1. $Id: NOTES,v 4.2 1994/10/23 23:35:07 ingber Exp ingber $
  2.  
  3. ========================================================================
  4.             CONTENTS (Search on these words.)
  5.  
  6. @@FORTRAN
  7. @@OPTIONS FOR LARGE SPACES
  8. @@SPECIAL COMPILATIONS
  9. @@PC CODE FOR TIME MODULES
  10. @@HP CODE FOR TIME MODULES
  11. @@EXAMPLES OF TUNING FOR SOME SYSTEMS
  12. @@RANDOM SEEDS
  13. @@CLARIFICATION OF GNU LICENSE
  14.  
  15. ========================================================================
  16. ========================================================================
  17. @@FORTRAN
  18.  
  19. 20 May 93
  20.  
  21. Some users have requested a FORTRAN version of ASA.  I wrote early
  22. versions of VFSR in RATFOR and used ratfor to translate to FORTRAN,
  23. but picked C for my own convenience for these later versions.
  24.  
  25. There are at least two reasonable options for people using FORTRAN:
  26.  
  27. (1) If the FORTRAN code you use is relatively small compared to
  28. the ASA code, you might try f2c to change your FORTRAN source
  29. into C.  This code can be gotten from Netlib, by logging into
  30. netlib@research.att.com as netlib and then cd f2c.
  31.  
  32. (2) You can use CFORTRAN, available via anonymous ftp from
  33. zebra.desy.de to interface your FORTRAN and C source and/or binary
  34. codes.  It seems the easiest way to use this would be to call a FORTRAN
  35. cost function from within the ASA C cost_function().
  36.  
  37. (3) You can see if your compiler will accept a rather simple approach
  38. to calling your FORTRAN fcost() from the ASA C cost_function(), just
  39. passing only those variables to fcost() necessary for your
  40. calculation.  The procedure below worked on a Sun SPARC-2/4.1.3 using
  41. gcc and Sun's f77.
  42.  
  43. (a) For example, in the user.c file, use "#if 0" to bypass the test
  44. cost_function(), substituting your own, and of course properly
  45. initializing the rest of the program using the templates provided in
  46. user.c:
  47. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  48. {
  49. #if HAVE_ANSI
  50.   extern void fcost_ (double *q, double *x);    /* note "_" on fcost_ */
  51. #else
  52.   extern void fcost_ ();
  53. #endif
  54.   double q;                     /* returned by fcost_() */
  55.   fcost_ (&q, x);
  56.   *cost_flag = TRUE;            /* or, add some feedback from fcost_() */
  57.   return (q);
  58. #if 0
  59. #if ASA_TEST                    /* ASA test problem */
  60. ...
  61. #endif /* ASA_TEST */
  62. #endif
  63. }
  64. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  65. The requirement to use an "_" on the C-function call is machine
  66. dependent.
  67.  
  68. (b) Create a file, e.g., cost.f, containing your FORTRAN cost
  69. function, e.g., if the *parameter_dimension is 4, then:
  70. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  71.       subroutine fcost (q_n, x)
  72.       double precision q_n, x(4)
  73.       ...
  74.       q_n = ...
  75.       end
  76. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  77. Note that element x[0] in C is mapped to x(1) in FORTRAN.
  78.  
  79. (c) In the Makefile add to the "compile: " (tabbed) commands:
  80. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  81. compile: $(USEROBJS) $(ASAOBJS)
  82.         f77 -c cost.f -lm
  83.         @$(CC) $(LDFLAGS) -o asa_run $(USEROBJS) $(ASAOBJS) cost.o -lm
  84. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  85. Some compilers may require the addition of additional libraries and
  86. options, e.g., -f77 on the CC line.  In general, it seems that the
  87. proper compiler to link all the object files, e.g., cc or f77, should
  88. correspond to the language of main().
  89.  
  90. ========================================================================
  91. ========================================================================
  92. @@OPTIONS FOR LARGE SPACES
  93.  
  94. 5 Oct 94
  95.  
  96. For very large parameter-space dimensions, the following guide is
  97. useful if you desire to speed up the search:
  98.  
  99.         Pre-Compile Options
  100. add -DUSER_REANNEAL_FUNCTION=TRUE to DEFINE_OPTIONS
  101. add -DUSER_COST_SCHEDULE=TRUE to DEFINE_OPTIONS
  102. add -DASA_PRINT_INTERMED=FALSE to DEFINE_OPTIONS
  103. SMALL_FLOAT may have to be decreased
  104.  
  105.         Program Options
  106. set CURVATURE_0 to TRUE
  107. set QUENCH_PARAMETERS to TRUE [a risk that negates proper sampling]
  108. set QUENCH_COST to TRUE
  109. set ACTIVATE_REANNEAL to FALSE
  110. decrease TEMPERATURE_RATIO_SCALE
  111. decrease COST_PARAMETER_SCALE
  112. increase MAXIMUM_COST_REPEAT
  113. decrease TESTING_FREQUENCY_MODULUS
  114.  
  115.         run time
  116. use `nice -19 asa_run ...` as runs can be time- and CPU-intensive
  117.  
  118. If the parameter space dimension, D, is huge, e.g., 256x256=65536,
  119. then the exponential of the generating or acceptance index to the 1/D
  120. power hardly changes over even a few million cycles.  True annealing in
  121. such huge spaces can become prohibitively slow as the temperatures will
  122. hardly be diminished over these cycles.  This "curse of dimensionality"
  123. will face any algorithm seeking to explore an unknown space.  Then,
  124. the QUENCH_PARAMETERS and QUENCH_COST Program Options should be tried.
  125.  
  126. However, note that slowing down annealing sometimes can speed up the
  127. search by avoiding spending too much time in some local optimal
  128. regions.
  129.  
  130. ========================================================================
  131. ========================================================================
  132. @@SPECIAL COMPILATIONS
  133.  
  134. 17 Dec 93
  135.  
  136. On an Intel Paragon Supercomputer, Graham Campbell
  137. <campbell@ams.sunysb.edu> reports that the ASA test problem runs
  138. without error or warning using gcc-2.4.5 as gcc -g -Wall.  However,
  139. when using cc -O or gcc -g -O, compilation fails.
  140.  
  141. ========================================================================
  142. 29 Mar 93
  143.  
  144. A problem in compilation,
  145. } Though I compiled successfully
  146. } on an old SUN 4/260 and a new IBM risc 6000 using both ansi c and
  147. } old version c, troubles comes in when I try it on a newly obtained
  148. } HWSs310 sparc workstation (claimed to be equivalent to sparc 10).
  149. } When using cc compiler, both user.c and asa.c have been compiled,
  150. } and it gave error message:
  151. } undefined symbol  -dlopen
  152. }                   _dlclose
  153. }                   _dlsym
  154. was solved by Walter Roberson <roberson@hamer.ibd.nrc.ca> by linking
  155. with -ldl.
  156. ========================================================================
  157. 15 Jan 93
  158.  
  159. Davyd Norris <daffy@vaxc.cc.monash.edu.au> reports that compilation
  160. was successful on a Pyramid:
  161. "On Pyramid OSx the -Xa compiler option had to be added so that the
  162. compiler knows to expect ANSI code.  Also on our system there is no
  163. stdlib.h include file."
  164.  
  165. ========================================================================
  166. ========================================================================
  167. @@PC CODE FOR TIME MODULES
  168.  
  169. 4 May 94
  170.  
  171. From selveria@salem.sylvania.com Wed May  4 11:19:58 1994
  172. From: "Selverian, John" <selveria@salem.sylvania.com>
  173. To: "Ingber, Lester" <ingber@alumni.caltech.edu>
  174. Subject: time calculation
  175. Date: Wed, 04 May 94 14:19:00 PDT
  176.  
  177. Lester,
  178.  
  179. I move my code (along with ASA) back and forth between a PC & a UNIX
  180. machine.  The time commands work fine on the UNIX machine but not on
  181. the PC.  I currently use the ansi <time.h> header file and the
  182. following command to get the time
  183.  
  184. #include <time.h>
  185. ...
  186. main()
  187. {
  188.       double  start_time,end_time,elapsed_time;
  189.       time_t    tloc;
  190. ...
  191.       start_time = (double)time(&tloc);     /* define starting time */
  192.       asa_main(....);                       /* call ASA */
  193.       end_time = (double)time(&tloc);       /* define ending time */
  194.       elapsed_time = end_time - start_time; /* define time spend in ASA */
  195. ...
  196. }
  197.  
  198. This works on both machines & I would guess with all ansi-C compliers.
  199.  
  200. JS
  201.  
  202. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  203. 14 Apr 94
  204. Note that there now is only one set of time routines in asa.c, and that
  205. now both asa.c and user.c pass two arguments to print_time(char
  206. *message, FILE * ptr_asa_out).
  207.  
  208. ========================================================================
  209. 18 Aug 93
  210.  
  211. For Turbo C, Davyd.Norris@physics.monash.edu.au suggests adding another
  212. include file, tcdefs.h, after
  213. #include <stdlib.h>
  214. in asa.h and in user.h.
  215. /***** tcdefs.h */
  216. /* Custom defines for Turbo C 2.0 and above */
  217. #include <float.h>
  218. #define MAX_DOUBLE    DBL_MAX
  219. #define MIN_DOUBLE    DBL_MIN
  220. #define EPS_DOUBLE    DBL_EPSILON
  221. }
  222. /*****/
  223.  
  224. He also suggests:
  225. } When compiling for Turbo/MS C, you need to set INT_ALLOC=TRUE and
  226. } INT_LONG=TRUE.  Lotsa warnings about unused variables, but no errors
  227. } or warnings that might mean something more serious.
  228.  
  229. ========================================================================
  230. 27 Aug 93
  231.  
  232. From zg11@midway.uchicago.edu Thu Aug 26 19:50:31 1993
  233. Return-Path: <zg11@midway.uchicago.edu>
  234. Date: Thu, 26 Aug 93 21:53:02 CDT
  235. From: "zening  ge" <zg11@midway.uchicago.edu>
  236. Subject: asa on PC
  237.  
  238. I have had the version 1.4 asa codes compiled using Turbo C++ 3.0 on my
  239. 386SX25 PC. The only thing needs to be changed is to set IO_PROTOTYPE
  240. to FALSE.
  241.  
  242. It is necessary to turn IO_PROTOTYPES to FALSE to avoid the errors of
  243. type mismatch in redefining "fprintf", "fflush", etc. For your example
  244. problem, it took about 5 minutes to complete the computation on my
  245. 386SX25 PC without math-coprocessor.
  246.  
  247. ========================================================================
  248. 31 Aug 93
  249.  
  250. Return-Path: <selveria@salem.sylvania.com>
  251. From: "Selverian, John" <selveria@salem.sylvania.com>
  252. To: "'Ingber, Lester'" <ingber@alumni.cco.caltech.edu>
  253. Date: Tue, 31 Aug 93 13:58:00 PDT
  254.  
  255. thanks for the tip.
  256.  
  257. Setting INT_ALLOC = TRUE and INT_LONG = TRUE solved the problem. Now
  258. the PC and SGI give the same answers.
  259.  
  260. Just for your info I am running a 486 66Mhz PC with a math co-processor
  261. with MS Quick C for Windows version 1.0.
  262.  
  263. ========================================================================
  264. ========================================================================
  265. @@HP CODE FOR TIME MODULES
  266.  
  267. 4 Nov 93
  268.  
  269. The changes recommended below for hpux have been implemented using the
  270. TIME_STD DEFINE_OPTION.
  271. ________________________________________________________________________
  272. 13 Sep 93
  273.  
  274. Sonja Zwissler <zwissler@askdonald.ask.uni-karlsruhe.de> wrote:
  275.  
  276. I have published the new version of asa on the ftp-server:
  277. hpux.ask.uni-karlsruhe.de, which also means a publication on
  278. ftp.csc.liv.ac.uk, ftp.cae.wisc.edu, hpux.cict.fr and some non-official
  279. mirror-sites.
  280.  
  281. ========================================================================
  282. ========================================================================
  283. @@EXAMPLES OF TUNING FOR SOME SYSTEMS
  284.  
  285. 12 Feb 93
  286.  
  287. The "Colville" problem required some parameter tuning.  In this case,
  288. I felt the default options gave starting cost-temperature rates too
  289. high, so I changed this scale.  I selected the starting values at
  290. the arbitrary points 0, added greater precision, and also permitted
  291. the runs to go longer than the "standard" specifications.  Using the
  292. ASA options given below, the actual set of optimal parameters is
  293. found to machine precision.  ASA achieves the actual global minimum
  294. (within machine precision).  I did not spend any extra time fine-tuning
  295. options to increase ASA efficiency.
  296.  
  297. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  298. CC = gcc
  299.         -g
  300.         -O
  301.         -Wall
  302.         -DSMALL_FLOAT=1.0E-35
  303.         -DLIMIT_ACCEPTANCES=50000
  304.         -DTEMPERATURE_ANNEAL_SCALE=1000
  305.         -DCOST_PARAMETER_SCALE=1.0E-1
  306.         -DUSER_INITIAL_PARAMETERS=TRUE
  307.         -DACCEPTED_TO_GENERATED_RATIO=1.0E-4
  308.  
  309. parameter_dimension = 4;
  310.  
  311. for (n = 0; n < 4; ++n) {
  312.     parameter_lower_bound[n] = -10.0;
  313.     parameter_upper_bound[n] = 10.0;
  314.     cost_parameters[n] = 0.0;
  315.     parameter_int_real[n] = REAL_TYPE;
  316. }
  317.  
  318. summ = 100.*(x[1]-(x[0]*x[0]))*(x[1]-(x[0]*x[0]))
  319.     + (1.-x[0])*(1.-x[0])
  320.     + 90.*(x[3]-(x[2]*x[2]))*(x[3]-(x[2]*x[2]))
  321.     + (1.-x[2])*(1.-x[2])
  322.     + 10.1*((x[1]-1.)*(x[1]-1.) + (x[3]-1.)*(x[3]-1.))
  323.     + 19.8*(x[1]-1.)*(x[3]-1.);
  324.  
  325. return (summ);
  326. ________________________________________________________________________
  327. RESULTS
  328.  
  329. best_generated_state=23.69555     number_accepted=120 number_generated=232
  330. best_generated_state=0.2942304    number_accepted=429 number_generated=2496
  331. best_generated_state=0.0005834838 number_accepted=733 number_generated=6229
  332. best_generated_state=7.848137e-05 number_accepted=3185 number_generated=44762
  333. best_generated_state=6.384848e-15 number_accepted=19968 number_generated=604224
  334. [Here, all the best parameters were 1 to printout precision, %12.7g.]
  335. best_generated_state=7.750362e-23 number_accepted=30510 number_generated=1767254
  336. [About here some current_parameter_temperature's became the order of
  337. SMALL_FLOAT.  Resetting SMALL_FLOAT would produce much more efficient
  338. calculations at and after this point, assuming machine precision is
  339. still meaningful.]
  340. best_generated_state=3.736047e-24 number_accepted=33046 number_generated=2194731
  341.  
  342. ========================================================================
  343. ========================================================================
  344. @@RANDOM SEEDS
  345.  
  346. Date: Fri, 30 Sep 94 11:04:44 +0100
  347. From: jarausch@igpm.igpm.rwth-aachen.de (Helmut Jarausch)
  348.  
  349. When calling asa_main(), the random generator always starts with the
  350. same seed. I have introduced the tiny routine asa_seed
  351. ________________________________________________________________________
  352. static LONG_INT seed = 696969;
  353. double random_array[SHUFFLE]; /* random variables */
  354.  
  355. #if HAVE_ANSI
  356. LONG_INT asa_seed(LONG_INT s)
  357. {
  358. #else
  359. asa_seed(s)
  360. { LONG_INT s;
  361. #endif
  362.   if ( s > 0 ) seed= s;
  363.   return seed;
  364. }
  365. ________________________________________________________________________
  366. which I can call prior to asa_main() to set the seed.
  367.  
  368. ========================================================================
  369. ========================================================================
  370. @@CLARIFICATION OF GNU LICENSE
  371.  
  372. 19 Dec 92
  373.  
  374. Some added clarification of the GNU license:
  375.  
  376. Date: Sat, 19 Dec 92 14:07:45 PST
  377. From: david d `zoo' zuhn <zoo@cygnus.com>
  378. Organization: Cygnus Support -- +1 415 903 1434
  379.  
  380. The LGPL says that if you use an LGPL covered library in your program, you
  381. must do two things:
  382.  
  383. 1) Provide the source code for the version of the library that you used,
  384.    including any local changes that you have made.
  385.  
  386. 2) Provide a means for the user to compile a new version of the library and
  387.    re-link that with the initial application, to get the benefits of
  388.    changing the LGPL covered source.  This is easiest done via shared
  389.    libraries, but shipping .o files is acceptable.
  390.  
  391. ========================================================================
  392. ========================================================================
  393.